<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    function getMaxAndMin(arr){
      let max = arr[0];
      let min = arr[0];
      for(var i=0;i<arr.length;i++){
        if(arr[i]>max){
          max = arr[i];
        }
        if(arr[i]<min){
          min = arr[i];
        }
      }
      // return {max,min};//返回多个数据
      return [max,min];//返回一个数组
    }
    let result = getMaxAndMin([1,2,3,4,5,6,7,8,9,10]);
    console.log(result);
  </script>
</body>
</html>